package com.erp.module.jiehao.scJieHao

import android.content.Context
import android.util.Log
import com.erp.Interface.OnUserDataInterface
import org.json.JSONArray
import org.json.JSONException

/**
 * Created by Administrator on 2017/11/17/017.
 * 作者：刘洋
 */
class IScJieHaoKP(val scJieHaoKView: ScJieHaoKView, val context :Context): ScJieHaoKP {

    var md  =ScJieHaoModel()
    var code=0
    override fun leixingcode(code: Int) {
        this.code=code
    }
    override fun addJieHao(jiehaolist: MutableList<String>) {
        var js=JSONArray()
        try {
            for(s in jiehaolist){
                js.put(s)
            }
        }catch (e : JSONException){
            e.printStackTrace()
        }
        Log.d("fenPeiJieHao",js.toString())
        md.addjiehao(context,js.toString(),code,object : OnUserDataInterface{
            override fun onUserData(data: String) = scJieHaoKView.addJieHaoOK(data)

            override fun onNot(throwable: String) = scJieHaoKView.addJieHaoNo(throwable)

        })
    }

}